@import '../variables/default.scss';
@import '../mixins/index.scss';

$at-tab-bar-min-height: 50px;
$at-tab-bar-title-max-width: 200px;
$at-tab-bar-without-dot-height: 104px;

.at-tab-bar {
  display: flex;
  padding: $spacing-v-sm 0 $spacing-v-xs;
  width: 100%;
  min-height: $at-tab-bar-min-height;
  justify-content: center;
  align-items: flex-start;
  text-align: center;
  box-sizing: border-box;
  background-color: $at-tab-bar-bg-color;
  @include hairline-top();

  &.at-tab-bar-without-dot {
    padding: 5.5px * $hd 0;

    .at-tab-bar__item {
      padding: 0;

      .at-tab-bar__icon {
        display: flex;
      }
    }
  }

  /* hack flex失效 https://developers.weixin.qq.com/community/develop/doc/000a20465f8ef84757b6f2f0456800 */
  /* stylelint-disable-next-line */
  at-tab-bar-item {
    display: contents;
  }

  /* elements */
  &__item {
    flex: 1;
    display: inline-block;
    padding: $spacing-v-sm $spacing-v-sm 0;
    color: $at-tab-bar-color;
    font-size: 0;
    transition: all 0.2s;

    &--active {
      color: $at-tab-bar-color-active;
    }

    &--custom {
      position: relative;

      &-icon {
        position: absolute;
        left: 0;
        right: 0;
        top: -36px;
        z-index: $zindex-dropdown;
        width: $at-tab-bar-icon-image-size-lg !important;
        height: $at-tab-bar-icon-image-size-lg !important;
        margin: auto;
      }

      &-title {
        padding-top: 54px;
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
      }
    }
  }

  &__icon {
    display: inline-block;
    font-size: $at-tab-bar-icon-font-size;
    line-height: 1;
  }

  &__inner-img {
    display: inline-block;
    width: $at-tab-bar-icon-image-size;
    height: $at-tab-bar-icon-image-size;

    &--inactive {
      display: none;
    }
  }

  &__title {
    display: inline-block;
    padding: $spacing-v-xs 0;
    max-width: $at-tab-bar-title-max-width;
    font-size: $at-tab-bar-font-size;
    line-height: $line-height-base;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* modifiers */
  &--fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding-bottom: calc(constant(safe-area-inset-bottom) + #{$spacing-v-xs});
    padding-bottom: calc(env(safe-area-inset-bottom) + #{$spacing-v-xs});
    z-index: $zindex-nav;

    &.at-tab-bar-without-dot {
      padding-bottom: calc(constant(safe-area-inset-bottom) + 5.5px * #{$hd});
      padding-bottom: calc(env(safe-area-inset-bottom) + 5.5px * #{$hd});
    }
  }

  &--ipx {
    &.at-tab-bar--fixed {
      padding-bottom: 68px;
    }
  }
}
